import requests

print("===== 显示所有响应头测试 =====\n")

base_url = "http://localhost:8001"

# 测试1: 带Origin头的简单GET请求
print("\n[测试1] 带Origin头的简单GET请求:")
headers = {"Origin": "http://example.com"}
response = requests.get(f"{base_url}/", headers=headers)
print(f"状态码: {response.status_code}")
print("\n所有响应头:")
for key, value in response.headers.items():
    print(f"  {key}: {value}")

# 测试2: 预检OPTIONS请求
print("\n[测试2] 预检OPTIONS请求:")
headers = {
    "Origin": "http://example.com",
    "Access-Control-Request-Method": "POST",
    "Access-Control-Request-Headers": "Content-Type"
}
response = requests.options(f"{base_url}/", headers=headers)
print(f"状态码: {response.status_code}")
print("\n所有响应头:")
for key, value in response.headers.items():
    print(f"  {key}: {value}")

print("\n===== 测试完成 =====\n")
print("请检查上面的响应头输出，确认CORS头是否正确设置。")